﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class ProductManager_OrderDetail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["ID"] != null)
            {
                int orderID = Convert.ToInt32(Request.QueryString["ID"]);
                hidOrderId.Value = Request.QueryString["ID"].ToString();
                InitialPage(orderID);
            }
        }
    }

    private void InitialPage(int orderID)
    {
        gvEachOrder.DataSource = ordBean.GetOrderEachPrdct(orderID);
        gvEachOrder.DataBind();

        List<GoShopping.Model.Order> listOrder = new List<GoShopping.Model.Order>();
        listOrder.Add(ordBean.GetOneOrder(orderID));
        fvPrdtCost.DataSource = listOrder;
        fvPrdtCost.DataBind();

        fvOther.DataSource = listOrder;
        fvOther.DataBind();

        fvCustomer.DataSource = listOrder;
        fvCustomer.DataBind();

        fvReceiver.DataSource = listOrder;
        fvReceiver.DataBind();
    }

    protected void btnPay_Click(object sender, EventArgs e)
    {
        Response.Redirect("GatheringRecords.aspx?ID=" + hidOrderId.Value);
        //跳转到GatheringRecords.aspx
        //更新支付金额
        //更新后台订单状态
    }
    protected void btnReturnMoney_Click(object sender, EventArgs e)
    {
        Response.Redirect("ReturnCashRecords.aspx?ID=" + hidOrderId.Value);
        //已支付金额不为空时,可以点退款,并清空已支付金额
        //更新后台订单状态
    }
    protected void btnSend_Click(object sender, EventArgs e)
    {
        Response.Redirect("SendPrdt.aspx?ID=" + hidOrderId.Value);
        //跳转到发货单页面
    }
    protected void btnReturnPrdt_Click(object sender, EventArgs e)
    {
        Response.Redirect("ReturnPrdt.aspx?ID=" + hidOrderId.Value);
        //跳转到退货单页面
    }
    protected void btnFinish_Click(object sender, EventArgs e)
    {
        //置所有Button为Disable
        //更新后台订单状态
    }
    protected void btnAbolish_Click(object sender, EventArgs e)
    {
        //置所有Button为Disable
        //更新后台订单状态
    }

    #region Seperate get page control data
    GoShopping.BLL.Orders.GatheringRecordsBean gatherRecBean = new GoShopping.BLL.Orders.GatheringRecordsBean();
    GoShopping.BLL.Orders.InvoiceBean invBean = new GoShopping.BLL.Orders.InvoiceBean();
    GoShopping.BLL.Orders.OrderBean ordBean = new GoShopping.BLL.Orders.OrderBean();
    GoShopping.BLL.Orders.ReturnCashRecordsBean returnCashBean = new GoShopping.BLL.Orders.ReturnCashRecordsBean();
    GoShopping.BLL.Orders.ReturnPrtsRecordsBean returnPrdtBean = new GoShopping.BLL.Orders.ReturnPrtsRecordsBean();

    GoShopping.Model.Order od = new GoShopping.Model.Order();
    GoShopping.Model.OrderEachProduct odEachPrdt = new GoShopping.Model.OrderEachProduct();
    GoShopping.Model.OrderStatus odStatus = new GoShopping.Model.OrderStatus();
    void GetOrderEachPrdtGV(int orderId)
    {
        gvEachOrder.DataSource = ordBean.GetOrderEachPrdct(orderId);
        gvEachOrder.DataBind();
    }
    void GetPrdtsCostDV(int orderId)
    {
        List<GoShopping.Model.Order> listOrder = new List<GoShopping.Model.Order>();
        listOrder.Add(ordBean.GetOneOrder(orderId));
        fvPrdtCost.DataSource = listOrder;
        fvPrdtCost.DataBind();
    }
    void GetOrderOtherDV(int orderId)
    {
        List<GoShopping.Model.Order> listOrder = new List<GoShopping.Model.Order>();
        listOrder.Add(ordBean.GetOneOrder(orderId));
        fvOther.DataSource = listOrder;
        fvOther.DataBind();
    }
    void GetCustomerDV(int orderId)
    {
        List<GoShopping.Model.Order> listOrder = new List<GoShopping.Model.Order>();
        listOrder.Add(ordBean.GetOneOrder(orderId));
        fvCustomer.DataSource = listOrder;
        fvCustomer.DataBind();
    }
    void GetReceiverDV(int orderId)
    {
        List<GoShopping.Model.Order> listOrder = new List<GoShopping.Model.Order>();
        listOrder.Add(ordBean.GetOneOrder(orderId));
        fvReceiver.DataSource = listOrder;
        fvReceiver.DataBind();
    }
    #endregion
}
